package CH8;

/**
 * Created by Cai Ye on 2016/4/24.
 */

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import static java.lang.System.out;

public class Ls {
    public static void main(String[] args) throws IOException {
        String glob = args.length == 0 ? "*" : args[0];
        Path userPath = Paths.get(System.getProperty("user.dir"));
        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(userPath, glob)) {
            directoryStream.forEach(path -> out.println(path.getFileName()));
        }
    }
}
